﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace App.Components
{
    //========================================================
    // UIAttribute
    //========================================================
    /// <summary>
    /// 描述字段 
    /// </summary>
    public class UIAttribute : Attribute
    {
        /// <summary>标题</summary>
        public string Title { get; set; }

        /// <summary>分组</summary>
        public string Group { get; set; }

        /// <summary>格式化字符串</summary>
        public string FormatString { get; set; }




        //---------------------------------------------
        // 自动计算字段
        //---------------------------------------------
        // 全名 
        public string FullTitle
        {
            get
            {
                if (string.IsNullOrEmpty(Group)) return Title;
                else return string.Format("{0}-{1}", Group, Title);
            }
        } 


        //---------------------------------------------
        // 构造函数
        //---------------------------------------------
        public UIAttribute(string title, string group = null, string formatString = "{0}")
        {
            this.Title = title;
            this.FormatString = formatString;
            this.Group = group;
        }
    }

}
